<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <script src="js/swiper-4.2.6.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="css/swiper-4.2.6.min.css"/>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="js/font.js"></script>
    <link rel="stylesheet" href="css/base.css">
    <script src="js/public.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" href="css/ui.css">
    <title></title>
    <!-- 个人中心-设置-信息完善-单位 -->
    <style>
    </style>
</head>
<body>
<div class="scroll-content2 my-setup-perfect-name" style="overflow:auto;background: #F5F5F5;">
    <div class="top-public">
        <span class="public-center">单位</span>        
        <img src="images/left_icon.png" alt="" class="public-left">
        <div class="public-right" onclick="update_company()">保存</div>
    </div>
    <div class="fillin-box">
        <input id="company" type="text" name="company" placeholder="请输入单位名称">
    </div>
</div>
</body>
<script>
$('.public-left').click(function(){
    window.history.go(-1);
})
</script>

<script>
    $(function() {
        //获取用户名
        userCompany();
    });
    function userCompany() {
        var company = sessionStorage.getItem('company');
        $('#company').val(company);
    }

    //用户修改单位
    function update_company() {
        var user_id = sessionStorage.getItem('userId');
        var company = $('#company').val();
        if (company==''){
            alert('请您填写单位名称！');
            return false;
        }
        $.ajax({
            url: url() + 'api/users/user_name_company',
            dataType: 'JSON',
            async: true, //请求是否异步，默认为异步，这也是ajax重要特性
            type: "POST", //请求方式
            data: {
                user_id:user_id,
                company:company
            },
            success: function (data) {
                console.log(data);
                if (data.status == 1) {
                    window.location.href = 'my_setup_perfect.html';
                } else {
                    alert(data.msg);
                }
            }
        });
    }
</script>

</html> 






